package com.tangzhe.demo10.controller;

import com.tangzhe.demo10.entity.Student;
import com.tangzhe.demo10.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * 学生控制层
 */
@Controller
@RequestMapping("/student")
public class StudentController {

    @Autowired
    private StudentService studentService;

    @RequestMapping("/findAll")
    public String findAll(Model model) {
        //调用业务查询
        List<Student> students = studentService.findAll();

        //将学生列表返回给页面
        model.addAttribute("students", students);

        //返回页面
        return "student";
    }

}
